cmake_minimum_required(VERSION 3.5)
project(subscribe_pointcloud VERSION 2.0.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(unitree_dir /opt/unitree_robotics)
set(unitree_include_dir ${unitree_dir}/include)
set(unitree_lib_dir ${unitree_dir}/lib)

set(ddscxx_dir /opt/unitree_robotics/include/ddscxx)
set(ddscxx_include_dir ${ddscxx_dir})

set(ddsc_dir /opt/unitree_robotics/include/ddsc)
set(ddsc_dir ${ddsc_dir})

find_package(Threads REQUIRED)

include_directories(${unitree_include_dir} ${ddscxx_include_dir} ${ddsc_dir})

# Prefer target-specific commands over link_directories
add_executable(${PROJECT_NAME} subscribe_pointcloud.cpp)

# Combine linking commands and specify order
target_link_libraries(${PROJECT_NAME}
    unitree_sdk2
    pthread
    unitree_sdk2 ddsc ddscxx rt
)

# Use target_link_directories instead of link_directories
target_link_directories(${PROJECT_NAME} PRIVATE ${unitree_lib_dir})
